home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////////////////////////////////////////////////
- // compoun.h: Compound number class definition.
- // Copyright (c) 1992 Azarona Software. All rights reserved.
- //////////////////////////////////////////////////////////////////////
- #ifndef H_COMPOUND
- #define H_COMPOUND
- #include "rational.h"
-
- class Compound {
- private:
- long w; // Whole number part
- Rational f; // Fractional part
- public:
- // Constructors and assignment
- Compound();
- Compound(long n);
- Compound(long n, Rational &r);
- Compound(Compound const &c);
- Compound &operator=(Compound const &c);
- // Helper functions
- void Simplify();
- void Set(long n, Rational &r);
- void Invert();
- void Negate();
- int IsUndefined() const;
- int IsNegative() const;
- int IsPositive() const;
- int IsZero() const;
- // Stream I/O operators
- friend istream &operator>>(istream &s, Compound &c);
- friend ostream &operator<<(ostream &s, const Compound &c);
- // Arithmetic operators that modify their operand
- Compound operator++(int); // Postfix
- Compound operator--(int); // Postfix
- Compound &operator++(); // Prefix
- Compound &operator--(); // Prefix
- Compound &operator+=(const Compound &r);
- Compound &operator-=(const Compound &r);
- Compound &operator*=(const Compound &r);
- Compound &operator/=(const Compound &r);
- // Arithmetic operators resulting in new object
- Compound operator-() const;
- Compound operator+() const;
- friend Compound operator+(const Compound &a, const Compound &b);
- friend Compound operator-(const Compound &a, const Compound &b);
- friend Compound operator*(const Compound &a, const Compound &b);
- friend Compound operator/(const Compound &a, const Compound &b);
- // Comparison operators
- friend int operator==(const Compound &a, const Compound &b);
- friend int operator!=(const Compound &a, const Compound &b);
- friend int operator<(const Compound &a, const Compound &b);
- friend int operator<=(const Compound &a, const Compound &b);
- friend int operator>(const Compound &a, const Compound &b);
- friend int operator>=(const Compound &a, const Compound &b);
- };
-
- #endif
-
-